﻿using System;
using System.Collections.Generic;

namespace WareDealer.Mode
{
    public interface IProcessOut
    {
        /// <summary>
        /// 进度条编号、名称
        /// </summary>
        List<string> ProcessBarIDs { get; set; }
        /// <summary>
        /// 初始化线程
        /// </summary>
        /// <remarks>用于进度条准备工作</remarks>
        Action<string,int> InitProcess { get; set; }
        /// <summary>
        /// 操作进度条
        /// </summary>
        Action<string, int> ShowStep { get; set; }
        /// <summary>
        /// 显示消息
        /// </summary>
        Action<string> ShowMessage { get; set; }
        /// <summary>
        /// 线程完成
        /// </summary>
        Action<string, bool> EndProcess { get; set; }
    }

    /// <summary>
    /// 接口样例
    /// </summary>
    public class ProcessOut : IProcessOut
    {
        public List<string> ProcessBarIDs { get; set; }
        public Action<string, int> InitProcess { get; set; }

        public Action<string, int> ShowStep { get; set; }

        public Action<string> ShowMessage { get; set; }

        public Action<string, bool> EndProcess { get; set; }

        #region Release Private Method

        private void InitAutoProcess(string processid, int iLength)
        {
            if (!string.IsNullOrEmpty(processid) && InitProcess != null)
            {
                InitProcess(processid, iLength);
            }
        }

        private void ShowAutoStep(string processid, int iStep)
        {
            if (!string.IsNullOrEmpty(processid) && ShowStep != null)
            {
                ShowStep(processid, iStep);
            }
        }

        private void EndAutoProcess(string processid, bool bRtn)
        {
            if (!string.IsNullOrEmpty(processid) && EndProcess != null)
            {
                EndProcess(processid, bRtn);
            }
        }

        private void ShowAutoMessage(string msg)
        {
            if (ShowMessage != null)
            {
                ShowMessage(msg);
            }
        }

        #endregion Release Private Method
        
    }
}
